package com.ruoyi.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysInformation;
import com.ruoyi.project.system.service.ISysInformationService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 平台信息Controller
 * 
 * @author jjp
 * @date 2020-04-15
 */
@RestController
@RequestMapping("/system/information")
public class SysInformationController extends BaseController
{
    @Autowired
    private ISysInformationService sysInformationService;

    /**
     * 查询平台信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:information:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysInformation sysInformation)
    {
        startPage();
        List<SysInformation> list = sysInformationService.selectSysInformationList(sysInformation);
        return getDataTable(list);
    }

    /**
     * 获取平台信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:information:query')")
    @GetMapping(value = "/{informationId}")
    public AjaxResult getInfo(@PathVariable("informationId") Long informationId)
    {
        return AjaxResult.success(sysInformationService.selectSysInformationById(informationId));
    }

    /**
     * 新增平台信息
     */
    @PreAuthorize("@ss.hasPermi('system:information:add')")
    @Log(title = "平台信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysInformation sysInformation)
    {
        return toAjax(sysInformationService.insertSysInformation(sysInformation));
    }

    /**
     * 修改平台信息
     */
    @PreAuthorize("@ss.hasPermi('system:information:edit')")
    @Log(title = "平台信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysInformation sysInformation)
    {
        return toAjax(sysInformationService.updateSysInformation(sysInformation));
    }

    /**
     * 删除平台信息
     */
    @PreAuthorize("@ss.hasPermi('system:information:remove')")
    @Log(title = "平台信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{informationIds}")
    public AjaxResult remove(@PathVariable Long[] informationIds)
    {
        return toAjax(sysInformationService.deleteSysInformationByIds(informationIds));
    }
}
